<!--- ==================================================
CURRENT VERSION:	1.0
DESC:  This tag is used to perform error handling for xti calls.
NOTE: 
INPUT PARAMS:
	<cf_xti_error_handler
	 		returnvar= [this needs to be the same as the returnvar specified in the XTI call this is checking]
			break=[optional value that stops processing if an error occurs - not used when popup is enabled]
			popup=[optional value that will display error in a Javascript popup window]>
================================================== --->
<cfsetting enablecfoutputonly="yes">

<cfparam name="attributes.returnvar" default="">
<cfparam name="var.errormessage" default="">
<cfparam name="var.errorcode" default="">

<!--- //// Make sure the post returned an ACTIONCODE //// --->
<cfif NOT IsDefined("caller." & attributes.returnvar & ".actioncode")>
	<cfoutput>&nbsp;&nbsp;<font face="Arial" size="2" color="FF0000"><b>Could not retrieve error code details #attributes.returnvar#.</b></font><br></cfoutput>	
  <cfabort>
</cfif>

<!--- //// Evaluate the ACTIONCODE and set the appropriate error message (numbers after 911.) //// --->
<cfset var.errorcode = evaluate("caller." & attributes.returnvar & ".actioncode")>
<cfset var.count = Len(var.errorcode) - find(".", var.errorcode)>

<cfif var.count gt 0>
	<cfset var.errorcode = right(var.errorcode, var.count)>
<cfelse>
	<cfset var.errorcode = var.errorcode>
</cfif>
<!--- look for a custom error message --->
<cfquery name="get_error_message" datasource="#application.dsn#">
	asp_get_error_messages '#var.errorcode#'
</cfquery>

<cfoutput>
<font face="Arial" size="2" color="000000"><b>The following result was returned while processing your request:</b></font><br>
<font face="Arial" size="2" color="FF0000"><b>
<cfif get_error_message.recordcount gt 0>
 	#get_error_message.english_language_message#
<cfelse>
	<!--- Internal Order Process Error - Error Code #var.errorcode# --->
	<!--- show the message provided by max if available --->
	<cfif IsDefined("caller." & attributes.returnvar & ".actionmessage")>
		<cfset var.errormessage = evaluate("caller." & attributes.returnvar & ".actionmessage")>
		 <cfif var.errormessage neq 'Invalid Zip/City/State Combination'>   
			Internal Order Process Error - Error Code #var.errorcode#.
			<br>#var.errormessage#. 
		<cfelse>
			<cfset test=#var.errormessage#>
			<br>#var.errormessage#. Please revise your entry.
		</cfif>  
	</cfif>
</cfif>
</b></font><br>			
</cfoutput>	 

<cfsetting enablecfoutputonly="no">

